<template>
  <div class="app-container">
    <el-row>
      <el-button round type="primary" @click="createNew">添加</el-button>
      <el-button round type="success" @click="update">修改</el-button>
      <el-button round type="warning" @click="destory">删除</el-button>
    </el-row>
    <el-row>
      <el-table
        highlight-current-row
        :data="roleLs"
        @current-change="handleCurrentChange"
        stripe
        style="width: 100%"
      >
        <el-table-column prop="name" label="角色"> </el-table-column>
        <el-table-column prop="mark" label="备注"> </el-table-column>
        <el-table-column prop="tags" label="标签"> </el-table-column>
        <el-table-column prop="enable" :formatter="bf" label="启用">
        </el-table-column>
        <el-table-column prop="superadm" :formatter="bf" label="超级管理员">
        </el-table-column>
        <el-table-column prop="ctime" label="创建时间"> </el-table-column>
      </el-table>
    </el-row>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import { roles, saveRole } from "@/api/role";
@Component({
  name: "sys-perm",
})
export default class extends Vue {
  private async created() {
    this.roles();
  }

  private currentRow: any;

  private handleCurrentChange(v: any) {
    this.currentRow = v;
  }
  private bf(row: any, column: any, val: boolean) {
    return val ? "是" : "否";
  }

  private createNew() {
    this.$router.push({
      path: "/sys/edperm",
    });
  }
  private update() {
    this.$router.push({
      path: "/sys/edperm",
      query: { id: this.currentRow.id },
    });
  }

  private destory() {}

  private roleLs: Array<any> = [];

  private async roles() {
    let d: any = await roles({});
    this.roleLs = d.data;
  }
}
</script>